
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>pymatgen.analysis.chemenv.utils.defs_utils &#8212; pymatgen 2020.7.3 documentation</title>
    <link rel="stylesheet" href="../../../../../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../../../../../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../../../../../" src="../../../../../_static/documentation_options.js"></script>
    <script src="../../../../../_static/jquery.js"></script>
    <script src="../../../../../_static/underscore.js"></script>
    <script src="../../../../../_static/doctools.js"></script>
    <script src="../../../../../_static/language_data.js"></script>
    <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="index" title="Index" href="../../../../../genindex.html" />
    <link rel="search" title="Search" href="../../../../../search.html" />
 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-33990148-1']);
  _gaq.push(['_trackPageview']);
</script>

  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../../../pymatgen.html" accesskey="U">pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.analysis.chemenv.utils.defs_utils</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <h1>Source code for pymatgen.analysis.chemenv.utils.defs_utils</h1><div class="highlight"><pre>
<span></span><span class="c1"># coding: utf-8</span>
<span class="c1"># Copyright (c) Pymatgen Development Team.</span>
<span class="c1"># Distributed under the terms of the MIT License.</span>


<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">This module contains the definition of some objects used in the chemenv package.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="n">__author__</span> <span class="o">=</span> <span class="s2">&quot;David Waroquiers&quot;</span>
<span class="n">__copyright__</span> <span class="o">=</span> <span class="s2">&quot;Copyright 2012, The Materials Project&quot;</span>
<span class="n">__credits__</span> <span class="o">=</span> <span class="s2">&quot;Geoffroy Hautier&quot;</span>
<span class="n">__version__</span> <span class="o">=</span> <span class="s2">&quot;2.0&quot;</span>
<span class="n">__maintainer__</span> <span class="o">=</span> <span class="s2">&quot;David Waroquiers&quot;</span>
<span class="n">__email__</span> <span class="o">=</span> <span class="s2">&quot;david.waroquiers@gmail.com&quot;</span>
<span class="n">__date__</span> <span class="o">=</span> <span class="s2">&quot;Feb 20, 2016&quot;</span>

<span class="kn">from</span> <span class="nn">pymatgen.analysis.chemenv.utils.coordination_geometry_utils</span> <span class="kn">import</span> <span class="n">is_anion_cation_bond</span>

<span class="n">STATS_ENV_PAPER</span> <span class="o">=</span> <span class="s1">&#39;David Waroquiers, Xavier Gonze, Gian-Marco Rignanese, Cathrin Welker-Nieuwoudt, Frank Rosowski,</span><span class="se">\n</span><span class="s1">&#39;</span> \
                  <span class="s1">&#39;Michael Goebel, Stephan Schenk, Peter Degelmann, Rute Andre, Robert Glaum, and Geoffroy Hautier,</span><span class="se">\n</span><span class="s1">&#39;</span> \
                  <span class="s1">&#39;&quot;Statistical analysis of coordination environments in oxides&quot;,</span><span class="se">\n</span><span class="s1">&#39;</span> \
                  <span class="s1">&#39;Chem. Mater., 2017, 29 (19), pp 8346-8360,</span><span class="se">\n</span><span class="s1">&#39;</span> \
                  <span class="s1">&#39;DOI: 10.1021/acs.chemmater.7b02766</span><span class="se">\n</span><span class="s1">&#39;</span>


<div class="viewcode-block" id="chemenv_citations"><a class="viewcode-back" href="../../../../../pymatgen.analysis.chemenv.utils.defs_utils.html#pymatgen.analysis.chemenv.coordination_environments.chemenv_strategies.chemenv_citations">[docs]</a><span class="k">def</span> <span class="nf">chemenv_citations</span><span class="p">():</span>
    <span class="n">out</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="n">out</span> <span class="o">+=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">If you use the ChemEnv tool for your research, please consider citing the following reference(s) :</span><span class="se">\n</span><span class="s1">&#39;</span>
    <span class="n">out</span> <span class="o">+=</span> <span class="s1">&#39;==================================================================================================</span><span class="se">\n</span><span class="s1">&#39;</span>
    <span class="n">out</span> <span class="o">+=</span> <span class="n">STATS_ENV_PAPER</span>
    <span class="k">return</span> <span class="n">out</span></div>


<div class="viewcode-block" id="AdditionalConditions"><a class="viewcode-back" href="../../../../../pymatgen.analysis.chemenv.utils.defs_utils.html#pymatgen.analysis.chemenv.coordination_environments.chemenv_strategies.AdditionalConditions">[docs]</a><span class="k">class</span> <span class="nc">AdditionalConditions</span><span class="p">():</span>
    <span class="n">NO_ADDITIONAL_CONDITION</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">ONLY_ANION_CATION_BONDS</span> <span class="o">=</span> <span class="mi">1</span>
    <span class="n">NO_ELEMENT_TO_SAME_ELEMENT_BONDS</span> <span class="o">=</span> <span class="mi">2</span>
    <span class="n">ONLY_ANION_CATION_BONDS_AND_NO_ELEMENT_TO_SAME_ELEMENT_BONDS</span> <span class="o">=</span> <span class="mi">3</span>
    <span class="n">ONLY_ELEMENT_TO_OXYGEN_BONDS</span> <span class="o">=</span> <span class="mi">4</span>
    <span class="c1"># Short versions</span>
    <span class="n">NONE</span> <span class="o">=</span> <span class="n">NO_ADDITIONAL_CONDITION</span>
    <span class="n">NO_AC</span> <span class="o">=</span> <span class="n">NO_ADDITIONAL_CONDITION</span>
    <span class="n">ONLY_ACB</span> <span class="o">=</span> <span class="n">ONLY_ANION_CATION_BONDS</span>
    <span class="n">NO_E2SEB</span> <span class="o">=</span> <span class="n">NO_ELEMENT_TO_SAME_ELEMENT_BONDS</span>
    <span class="n">ONLY_ACB_AND_NO_E2SEB</span> <span class="o">=</span> <span class="n">ONLY_ANION_CATION_BONDS_AND_NO_ELEMENT_TO_SAME_ELEMENT_BONDS</span>
    <span class="n">ONLY_E2OB</span> <span class="o">=</span> <span class="n">ONLY_ELEMENT_TO_OXYGEN_BONDS</span>
    <span class="c1"># Dictionary mapping of integer for the condition and its &quot;description&quot;</span>
    <span class="n">CONDITION_DESCRIPTION</span> <span class="o">=</span> <span class="p">{</span><span class="n">NO_ADDITIONAL_CONDITION</span><span class="p">:</span> <span class="s1">&#39;No additional condition&#39;</span><span class="p">,</span>
                             <span class="n">ONLY_ANION_CATION_BONDS</span><span class="p">:</span> <span class="s1">&#39;Only anion-cation bonds&#39;</span><span class="p">,</span>
                             <span class="n">NO_ELEMENT_TO_SAME_ELEMENT_BONDS</span><span class="p">:</span> <span class="s1">&#39;No element-element bonds (same elements)&#39;</span><span class="p">,</span>
                             <span class="n">ONLY_ANION_CATION_BONDS_AND_NO_ELEMENT_TO_SAME_ELEMENT_BONDS</span><span class="p">:</span> <span class="s1">&#39;Only anion-cation bonds and&#39;</span>
                                                                                           <span class="s1">&#39; no element-element bonds&#39;</span>
                                                                                           <span class="s1">&#39; (same elements)&#39;</span><span class="p">,</span>
                             <span class="n">ONLY_ELEMENT_TO_OXYGEN_BONDS</span><span class="p">:</span> <span class="s1">&#39;Only element-oxygen bonds&#39;</span><span class="p">}</span>

    <span class="n">ALL</span> <span class="o">=</span> <span class="p">[</span><span class="n">NONE</span><span class="p">,</span> <span class="n">ONLY_ACB</span><span class="p">,</span> <span class="n">NO_E2SEB</span><span class="p">,</span> <span class="n">ONLY_ACB_AND_NO_E2SEB</span><span class="p">,</span> <span class="n">ONLY_E2OB</span><span class="p">]</span>

<div class="viewcode-block" id="AdditionalConditions.check_condition"><a class="viewcode-back" href="../../../../../pymatgen.analysis.chemenv.utils.defs_utils.html#pymatgen.analysis.chemenv.coordination_environments.chemenv_strategies.AdditionalConditions.check_condition">[docs]</a>    <span class="k">def</span> <span class="nf">check_condition</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="n">parameters</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">condition</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">NONE</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">True</span>
        <span class="k">elif</span> <span class="n">condition</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">ONLY_ACB</span><span class="p">:</span>
            <span class="n">valences</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">&#39;valences&#39;</span><span class="p">]</span>
            <span class="n">ii</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">&#39;site_index&#39;</span><span class="p">]</span>
            <span class="n">jj</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">&#39;neighbor_index&#39;</span><span class="p">]</span>
            <span class="k">return</span> <span class="n">is_anion_cation_bond</span><span class="p">(</span><span class="n">valences</span><span class="p">,</span> <span class="n">ii</span><span class="p">,</span> <span class="n">jj</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">condition</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">NO_E2SEB</span><span class="p">:</span>
            <span class="n">ii</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">&#39;site_index&#39;</span><span class="p">]</span>
            <span class="n">jj</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">&#39;neighbor_index&#39;</span><span class="p">]</span>
            <span class="n">elmts_ii</span> <span class="o">=</span> <span class="p">[</span><span class="n">sp</span><span class="o">.</span><span class="n">symbol</span> <span class="k">for</span> <span class="n">sp</span> <span class="ow">in</span> <span class="n">structure</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span><span class="o">.</span><span class="n">species</span><span class="p">]</span>
            <span class="n">elmts_jj</span> <span class="o">=</span> <span class="p">[</span><span class="n">sp</span><span class="o">.</span><span class="n">symbol</span> <span class="k">for</span> <span class="n">sp</span> <span class="ow">in</span> <span class="n">structure</span><span class="p">[</span><span class="n">jj</span><span class="p">]</span><span class="o">.</span><span class="n">species</span><span class="p">]</span>
            <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">elmts_ii</span><span class="p">)</span> <span class="o">&amp;</span> <span class="nb">set</span><span class="p">(</span><span class="n">elmts_jj</span><span class="p">))</span> <span class="o">==</span> <span class="mi">0</span>
        <span class="k">elif</span> <span class="n">condition</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">ONLY_ACB_AND_NO_E2SEB</span><span class="p">:</span>
            <span class="n">valences</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">&#39;valences&#39;</span><span class="p">]</span>
            <span class="n">ii</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">&#39;site_index&#39;</span><span class="p">]</span>
            <span class="n">jj</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">&#39;neighbor_index&#39;</span><span class="p">]</span>
            <span class="n">elmts_ii</span> <span class="o">=</span> <span class="p">[</span><span class="n">sp</span><span class="o">.</span><span class="n">symbol</span> <span class="k">for</span> <span class="n">sp</span> <span class="ow">in</span> <span class="n">structure</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span><span class="o">.</span><span class="n">species</span><span class="p">]</span>
            <span class="n">elmts_jj</span> <span class="o">=</span> <span class="p">[</span><span class="n">sp</span><span class="o">.</span><span class="n">symbol</span> <span class="k">for</span> <span class="n">sp</span> <span class="ow">in</span> <span class="n">structure</span><span class="p">[</span><span class="n">jj</span><span class="p">]</span><span class="o">.</span><span class="n">species</span><span class="p">]</span>
            <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">elmts_ii</span><span class="p">)</span> <span class="o">&amp;</span> <span class="nb">set</span><span class="p">(</span><span class="n">elmts_jj</span><span class="p">))</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">is_anion_cation_bond</span><span class="p">(</span><span class="n">valences</span><span class="p">,</span> <span class="n">ii</span><span class="p">,</span> <span class="n">jj</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">condition</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">ONLY_E2OB</span><span class="p">:</span>
            <span class="n">ii</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">&#39;site_index&#39;</span><span class="p">]</span>
            <span class="n">jj</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">&#39;neighbor_index&#39;</span><span class="p">]</span>
            <span class="n">elmts_ii</span> <span class="o">=</span> <span class="p">[</span><span class="n">sp</span><span class="o">.</span><span class="n">symbol</span> <span class="k">for</span> <span class="n">sp</span> <span class="ow">in</span> <span class="n">structure</span><span class="p">[</span><span class="n">ii</span><span class="p">]</span><span class="o">.</span><span class="n">species</span><span class="p">]</span>
            <span class="n">elmts_jj</span> <span class="o">=</span> <span class="p">[</span><span class="n">sp</span><span class="o">.</span><span class="n">symbol</span> <span class="k">for</span> <span class="n">sp</span> <span class="ow">in</span> <span class="n">structure</span><span class="p">[</span><span class="n">jj</span><span class="p">]</span><span class="o">.</span><span class="n">species</span><span class="p">]</span>
            <span class="k">return</span> <span class="p">(</span><span class="s1">&#39;O&#39;</span> <span class="ow">in</span> <span class="n">elmts_jj</span> <span class="ow">and</span> <span class="s1">&#39;O&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">elmts_ii</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="s1">&#39;O&#39;</span> <span class="ow">in</span> <span class="n">elmts_ii</span> <span class="ow">and</span> <span class="s1">&#39;O&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">elmts_jj</span><span class="p">)</span></div></div>
</pre></div>

            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../../../pymatgen.html" >pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.analysis.chemenv.utils.defs_utils</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright 2011, Pymatgen Development Team.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.1.2.
    </div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
  (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ?
              'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })();
</script>
</div>

  </body>
</html>